* debian/control: build-depend on attr, for the tests (only required if
/var/tmp supports extended attributes)
* debian/rules: warn if there are leftover daemon processes after testing
+ * debian/patches: add patches to get the build-time tests passing under
+ sbuild
-- Simon McVittie <smcv@debian.org> Mon, 28 Mar 2016 12:02:59 +0100
--- /dev/null
+From: Simon McVittie <smcv@debian.org>
+Date: Thu, 31 Mar 2016 08:27:32 +0100
+Subject: In tests that use gpg, terminate the gpg-agent after testing
+
+Otherwise we leak those processes.
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ tests/test-commit-sign.sh | 1 +
+ tests/test-gpg-signed-commit.sh | 2 ++
+ tests/test-pull-mirror-summary.sh | 2 ++
+ tests/test-pull-summary-sigs.sh | 2 ++
+ tests/test-remote-gpg-import.sh | 1 +
+ 5 files changed, 8 insertions(+)
+
+diff --git a/tests/test-commit-sign.sh b/tests/test-commit-sign.sh
+index 8d52bca..1b153e9 100755
+--- a/tests/test-commit-sign.sh
++++ b/tests/test-commit-sign.sh
+@@ -132,5 +132,6 @@ if ${CMD_PREFIX} ostree --repo=repo show main | grep -o 'Found [[:digit:]] signa
+ fi
+
+ rm -rf repo gnomerepo-files
++gpg-connect-agent --homedir ${test_tmpdir}/gpghome killagent /bye
+
+ echo "ok"
+diff --git a/tests/test-gpg-signed-commit.sh b/tests/test-gpg-signed-commit.sh
+index a0bf983..096c0e1 100755
+--- a/tests/test-gpg-signed-commit.sh
++++ b/tests/test-gpg-signed-commit.sh
+@@ -78,4 +78,6 @@ if ${OSTREE} show test2 | grep -o 'Found [[:digit:]] signature'; then
+ assert_not_reached
+ fi
+
++gpg-connect-agent --homedir ${test_tmpdir}/gpghome killagent /bye
++
+ echo "ok"
+diff --git a/tests/test-pull-mirror-summary.sh b/tests/test-pull-mirror-summary.sh
+index 20707a1..d5e27fc 100755
+--- a/tests/test-pull-mirror-summary.sh
++++ b/tests/test-pull-mirror-summary.sh
+@@ -121,3 +121,5 @@ echo "ok pull mirror with invalid summary sig and no verification"
+ # assert_file_has_content deltas.txt "${origmain}-${newmain}"
+
+ # echo "ok pull mirror with signed summary covering static deltas"
++
++gpg-connect-agent --homedir ${test_tmpdir}/gpghome killagent /bye
+diff --git a/tests/test-pull-summary-sigs.sh b/tests/test-pull-summary-sigs.sh
+index 202efda..dd2fcb0 100755
+--- a/tests/test-pull-summary-sigs.sh
++++ b/tests/test-pull-summary-sigs.sh
+@@ -133,3 +133,5 @@ assert_file_has_content summary.txt "Good signature from \"Ostree Tester <test@t
+ grep static-deltas summary.txt > static-deltas.txt
+ assert_file_has_content static-deltas.txt \
+ $(${OSTREE} --repo=repo rev-parse origin:main)
++
++gpg-connect-agent --homedir ${test_tmpdir}/gpghome killagent /bye
+diff --git a/tests/test-remote-gpg-import.sh b/tests/test-remote-gpg-import.sh
+index bb0c402..aa90eb8 100755
+--- a/tests/test-remote-gpg-import.sh
++++ b/tests/test-remote-gpg-import.sh
+@@ -143,4 +143,5 @@ if ${OSTREE} pull R2:main >/dev/null 2>&1; then
+ fi
+ ${OSTREE} pull R3:main >/dev/null
+
++gpg-connect-agent --homedir ${test_tmpdir}/gpghome killagent /bye
+ echo "ok"
--- /dev/null
+From: Simon McVittie <smcv@debian.org>
+Date: Thu, 31 Mar 2016 09:02:23 +0100
+Subject: Load g-i bindings from builddir during build-time testing
+
+Previously, the build-time tests would only pass if the g-i bindings to
+OSTree were already installed, with a reasonably similar version.
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ Makefile-tests.am | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile-tests.am b/Makefile-tests.am
+index 9eb9ad8..97f0541 100644
+--- a/Makefile-tests.am
++++ b/Makefile-tests.am
+@@ -22,8 +22,12 @@ include $(top_srcdir)/buildutil/glib-tap.mk
+ # We should probably consider flipping the default for DEBUG. Also,
+ # include the builddir in $PATH so we find our just-built ostree
+ # binary.
+-TESTS_ENVIRONMENT += OT_TESTS_DEBUG=1 \
+- PATH=$$(cd $(top_builddir) && pwd):$${PATH}
++TESTS_ENVIRONMENT += \
++ GI_TYPELIB_PATH=$$(cd $(top_builddir) && pwd) \
++ LD_LIBRARY_PATH=$$(cd $(top_builddir)/.libs && pwd) \
++ OT_TESTS_DEBUG=1 \
++ PATH=$$(cd $(top_builddir) && pwd):$${PATH} \
++ $(NULL)
+
+ test_scripts = \
+ tests/test-basic.sh \
--- /dev/null
+From: Simon McVittie <smcv@debian.org>
+Date: Mon, 28 Mar 2016 13:46:23 +0100
+Subject: Symlink libreaddir-rand.so into tests directory
+
+This means it can be LD_PRELOADed during build-time testing.
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ .gitignore | 1 +
+ Makefile-decls.am | 3 +++
+ Makefile-tests.am | 4 ++++
+ 3 files changed, 8 insertions(+)
+
+diff --git a/.gitignore b/.gitignore
+index d241cab..f37ca48 100644
+--- a/.gitignore
++++ b/.gitignore
+@@ -70,6 +70,7 @@ _build
+ /test-remote-add.test
+ /test-setuid.test
+ /test-xattrs.test
++/tests/libreaddir-rand.so
+ test-varint
+ test*.test
+ *.trs
+diff --git a/Makefile-decls.am b/Makefile-decls.am
+index a5c9d50..eefffd6 100644
+--- a/Makefile-decls.am
++++ b/Makefile-decls.am
+@@ -49,3 +49,6 @@ GITIGNOREFILES =
+ # This is a special facility to chain together hooks easily
+ INSTALL_DATA_HOOKS =
+ install-data-hook: $(INSTALL_DATA_HOOKS)
++
++ALL_LOCAL_RULES =
++all-local: $(ALL_LOCAL_RULES)
+diff --git a/Makefile-tests.am b/Makefile-tests.am
+index 9f359ad..9eb9ad8 100644
+--- a/Makefile-tests.am
++++ b/Makefile-tests.am
+@@ -211,6 +211,10 @@ EXTRA_DIST += \
+ tests/gpg-verify-data/trustdb.gpg \
+ tests/gpg-verify-data/gpg.conf
+
++tests-libreaddir-rand-so-symlink:
++ ln -fns ../.libs/libreaddir-rand.so tests
++ALL_LOCAL_RULES += tests-libreaddir-rand-so-symlink
++
+ # Unfortunately the glib test data APIs don't actually handle
+ # non-recursive Automake, so we change our code to canonically look
+ # for tests/ which is just a symlink when installed.
+test-xattrs-use-TAP-syntax-to-skip-test.patch
+various-tests-skip-if-temp-directory-lacks-xattr-support.patch
+Symlink-libreaddir-rand.so-into-tests-directory.patch
+tap-test-clean-up-temporary-test-directories-as-intended.patch
+In-tests-that-use-gpg-terminate-the-gpg-agent-after-testi.patch
+Load-g-i-bindings-from-builddir-during-build-time-testing.patch
--- /dev/null
+From: Simon McVittie <smcv@debian.org>
+Date: Thu, 31 Mar 2016 08:24:56 +0100
+Subject: tap-test: clean up temporary test directories as intended
+
+The script created ./.testtmp but looked for ./.test, which isn't
+going to work.
+
+This means the various "ostree trivial-httpd --autoexit" processes
+actually exit, because their web roots are cleaned up now.
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ buildutil/tap-test | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/buildutil/tap-test b/buildutil/tap-test
+index e791454..6b2eb5c 100755
+--- a/buildutil/tap-test
++++ b/buildutil/tap-test
+@@ -13,7 +13,7 @@ touch ${tempdir}/.testtmp
+ function cleanup () {
+ if test -n "${TEST_SKIP_CLEANUP:-}"; then
+ echo "Skipping cleanup of ${tempdir}"
+- else if test -f ${tempdir}/.test; then
++ else if test -f ${tempdir}/.testtmp; then
+ rm "${tempdir}" -rf
+ fi
+ fi
--- /dev/null
+From: Simon McVittie <smcv@debian.org>
+Date: Mon, 28 Mar 2016 13:08:32 +0100
+Subject: test-xattrs: use TAP syntax to skip test
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ tests/test-xattrs.sh | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tests/test-xattrs.sh b/tests/test-xattrs.sh
+index 6a83a0b..2f2d99c 100755
+--- a/tests/test-xattrs.sh
++++ b/tests/test-xattrs.sh
+@@ -21,7 +21,8 @@ set -euo pipefail
+
+ touch test-xattrs
+ if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
+- exit 77
++ echo "1..0 # SKIP: cannot run setfattr"
++ exit 0
+ fi
+
+ echo "1..2"
--- /dev/null
+From: Simon McVittie <smcv@debian.org>
+Date: Mon, 28 Mar 2016 13:18:42 +0100
+Subject: various tests: skip if temp directory lacks xattr support
+
+Some autobuilder environments place the entire build chroot on tmpfs, so
+even /var/tmp might not have this.
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ tests/test-basic-user.sh | 6 ++++++
+ tests/test-delta.sh | 7 +++++++
+ tests/test-demo-buildsystem.sh | 6 ++++++
+ tests/test-local-pull.sh | 6 ++++++
+ tests/test-prune.sh | 6 ++++++
+ tests/test-rofiles-fuse.sh | 6 ++++++
+ 6 files changed, 37 insertions(+)
+
+diff --git a/tests/test-basic-user.sh b/tests/test-basic-user.sh
+index f53de89..efe723c 100755
+--- a/tests/test-basic-user.sh
++++ b/tests/test-basic-user.sh
+@@ -19,6 +19,12 @@
+
+ set -euo pipefail
+
++touch test-xattrs
++if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
++ echo "1..0 # SKIP bare-user repository requires xattr support"
++ exit 0
++fi
++
+ echo "1..1"
+
+ . $(dirname $0)/libtest.sh
+diff --git a/tests/test-delta.sh b/tests/test-delta.sh
+index 12f54c7..4335779 100755
+--- a/tests/test-delta.sh
++++ b/tests/test-delta.sh
+@@ -156,6 +156,13 @@ ${CMD_PREFIX} ostree --repo=repo2 ls ${newrev} >/dev/null
+
+ echo 'ok pull delta'
+
++touch test-xattrs
++if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
++ echo "ok apply offline # SKIP bare-user repository requires xattr support"
++ echo "ok apply offline inline # SKIP bare-user repository requires xattr support"
++ exit 0
++fi
++
+ rm repo2 -rf
+ mkdir repo2 && ${CMD_PREFIX} ostree --repo=repo2 init --mode=bare-user
+ mkdir deltadir
+diff --git a/tests/test-demo-buildsystem.sh b/tests/test-demo-buildsystem.sh
+index 500eac6..6708e61 100755
+--- a/tests/test-demo-buildsystem.sh
++++ b/tests/test-demo-buildsystem.sh
+@@ -24,6 +24,12 @@ if ! fusermount --version >/dev/null 2>&1; then
+ exit 0
+ fi
+
++touch test-xattrs
++if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
++ echo "1..0 # SKIP bare-user repository requires xattr support"
++ exit 0
++fi
++
+ . $(dirname $0)/libtest.sh
+
+ echo "1..1"
+diff --git a/tests/test-local-pull.sh b/tests/test-local-pull.sh
+index a9beb08..c6df6ea 100755
+--- a/tests/test-local-pull.sh
++++ b/tests/test-local-pull.sh
+@@ -19,6 +19,12 @@
+
+ set -euo pipefail
+
++touch test-xattrs
++if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
++ echo "1..0 # SKIP bare-user repository requires xattr support"
++ exit 0
++fi
++
+ echo "1..1"
+
+ . $(dirname $0)/libtest.sh
+diff --git a/tests/test-prune.sh b/tests/test-prune.sh
+index 7184ea9..c2f4eb9 100755
+--- a/tests/test-prune.sh
++++ b/tests/test-prune.sh
+@@ -127,6 +127,12 @@ assert_file_has_content deltascount "^1$"
+
+ echo "ok prune"
+
++touch test-xattrs
++if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
++ echo "ok prune with partial repo # SKIP bare-user repository requires xattr support"
++ exit 0
++fi
++
+ rm repo -rf
+ ostree --repo=repo init --mode=bare-user
+ ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
+diff --git a/tests/test-rofiles-fuse.sh b/tests/test-rofiles-fuse.sh
+index 444fbce..d609cae 100755
+--- a/tests/test-rofiles-fuse.sh
++++ b/tests/test-rofiles-fuse.sh
+@@ -24,6 +24,12 @@ if ! fusermount --version >/dev/null 2>&1; then
+ exit 0
+ fi
+
++touch test-xattrs
++if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
++ echo "1..0 # SKIP bare-user repository requires xattr support"
++ exit 0
++fi
++
+ . $(dirname $0)/libtest.sh
+ setup_test_repository "bare-user"
+